<template>
	<view class="content">
		<view class="box">
			<button type="default" @click="admin('chongzhi')">重置用户</button>
			<button type="default" @click="admin('qingkong')">清空评论</button>
		</view>
		<view v-for="(item,index) in xinyuanList" :key="index" class="box">
			<text class="txt">{{item.xinyuan}}</text>
			<view class="btn-team">
				<!-- <button type="primary" size="mini" class="btn" @click="shenhe(1,item)">通过</button>
				<button type="warn" size="mini" class="btn" @click="shenhe(2,item)">拒绝</button> -->
				<button type="warn" size="mini" class="btn" @click="shenhe(3,item)">删除</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				xinyuanList: []
			}
		},
		onShow() {
			this.getList()
		},
		methods: {
			admin(flag) {
				uniCloud.callFunction({
					name: 'admin',
					data: {
						flag: flag
					}
				}).then(res => {
					console.log(res)
					uni.showToast({
						title: '成功',
						mask: true,
						icon: 'none'
					})
				})
			},
			getList() {
				uniCloud.callFunction({
					name: 'getzxinyuan-list',
					data: {
						sign: 2
					}
				}).then(res => {
					console.log(res)
					this.xinyuanList = res.result.data
				})
			},
			shenhe(status, item) {
				uniCloud.callFunction({
					name: 'xinyuanshenhe',
					data: {
						id: item._id,
						status: status
					}
				}).then(res => {
					this.getList()
				})
			}
		}
	}
</script>

<style lang="scss">
	.box {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		padding: 10rpx;
		border: 1px dashed #eee;
		width: calc(100% - 20rpx);

	}

	.txt {
		width: 70%;
	}

	.btn-team {
		display: flex;
		flex-direction: column;

		.btn {
			margin: 10rpx 0;
		}
	}
</style>
